package com.ouc.yyi.controller;
//
//                       _oo0oo_
//                      o8888888o
//                      88" . "88
//                      (| -_- |)
//                      0\  =  /0
//                    ___/`---'\___
//                  .' \\|     |// '.
//                 / \\|||  :  |||// \
//                / _||||| -:- |||||- \
//               |   | \\\  -  /// |   |
//               | \_|  ''\---/''  |_/ |
//               \  .-\__  '-'  ___/-. /
//             ___'. .'  /--.--\  `. .'___
//          ."" '<  `.___\_<|>_/___.' >' "".
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//         \  \ `_.   \_ __\ /__ _/   .-` /  /
//     =====`-.____`.___ \_____/___.-`___.-'=====
//                       `=---='
//
//
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//               佛祖保佑         永无BUG
//


import com.baomidou.mybatisplus.plugins.Page;
import com.ouc.yyi.config.model.Role;
import com.ouc.yyi.system.jsonBean.RoleJson;
import com.ouc.yyi.system.service.RoleService;
import javafx.print.PaperSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author: yyi
 * @date: 2019/2/22 15:40
 * @parameters:
 * @desc:
 **/
@Controller
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @RequestMapping("/index")
    public String roleIndex(){
        return "views/role/list.html";
    }
    @RequestMapping("/roleList")
    @ResponseBody
    public RoleJson roleList(@RequestParam(required = false) Integer page,@RequestParam(required = false) Integer limit ){
        RoleJson roleJson = new RoleJson();
        Page<Role> pages = roleService.selectPage(new Page<>(page,limit));
        roleJson.setData(pages.getRecords());
        roleJson.setCode(0);
        roleJson.setMsg("");
        roleJson.setCount((int) pages.getTotal());
        return roleJson;

    }

}
